<template>
    <BasePanel width="388px" height="140px" title="淳安特别生态功能区建设">
        <template #default>
            <div class="panel-content">
                <div v-for="item in listData" :key="item.label" class="item">
                    <div class="info-box">
                        <span class="label">{{ item.label }}</span>
                        <div class="value-box">
                            <span class="value">{{ item.total }}</span>
                            <span class="unit">{{ item.unit }}</span>
                        </div>
                    </div>
                    <div class="bar-box">
                        <PercentBar :list="transformPercentBarData(item)" />
                    </div>
                </div>
            </div>
        </template>
    </BasePanel>
</template>

<script setup lang="ts">
import BasePanel from '@/components/BasePanel/index.vue'
import PercentBar from '@/components/PercentBar/index.vue'
// import { useGlobalStore } from '@/store/global'
// import { getFpiAssetsFile } from '@/utils/tools'

// 全局数据
// const globalStore = useGlobalStore()

const listData = shallowRef([
    {
        label: '保护',
        total: '24',
        done: 18,
        unit: '项',
    },
    {
        label: '政策',
        total: 6,
        done: 6,
        unit: '项',
    },
])

// 转化数据
const transformPercentBarData = (info: any) => {
    return [
        {
            name: '完成',
            value: info.done,
            color: 'rgba(45, 255, 132, 1)',
        },
        {
            name: '未完成',
            value: info.total - info.done,
            color: 'rgba(255, 15, 0, 1)',
        },
    ]
}
</script>

<style lang="scss" scoped>
.panel-content {
    width: 100%;
    height: 100%;
    display: flex;
    gap: 24px;

    .item {
        flex: 1;
        height: 100%;
        width: 0;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 16px;

        .info-box {
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: center;

            .label {
                font-size: 18px;
                font-weight: 700;
                line-height: 18px;
                color: rgba(255, 255, 255, 1);
                height: 18px;
            }

            .value-box {
                display: flex;
                align-items: flex-end;
                gap: 4px;

                .value {
                    font-size: 24px;
                    font-weight: 400;
                    line-height: 24px;
                    color: rgba(1, 254, 133, 1);
                    height: 24px;
                    font-family: Oswald;
                }
                .unit {
                    font-size: 16px;
                    font-weight: 700;
                    line-height: 16px;
                    height: 16px;
                    color: rgba(255, 255, 255, 1);
                }
            }
        }

        .bar-box {
            width: 100%;
            height: 12px;
        }
    }
}
</style>
